import * as React from 'react'
import { createRoot } from 'react-dom/client'
import ZH_CN from 'antd/lib/locale-provider/zh_CN'
import { ConfigProvider } from 'antd'
import Popup from './components/Popup'
import { dispatch } from './store'
import { api_gitee } from '../../apis'
import { global_init } from '../../util/inits'

global_init()

createRoot(document.querySelector('#app')).render(<ConfigProvider locale={ZH_CN}>
    <Popup />
</ConfigProvider>)


const listenState = function loop () {
    dispatch(state => ({ ...state, loading: true }))
    api_gitee.user_info().then(res => {
        dispatch(state => ({...state, loginUser: res.data, loading: false}))
    }).finally(function () {
        setTimeout(loop, 20000)
    })
}
listenState()